package com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.model.DeviceService;

/**
 * Servlet implementation class DeviceImport
 */
@WebServlet("/DeviceImport")
public class DeviceImport extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static final String ERROR_PAGE = "DeviceImportFailed.jsp";
	private static final String SB_PAGE = "listSB.jsp";

    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeviceImport() {
        super();
    }

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		if( !DeviceService.deviceImport(request) ) {
			response.sendRedirect(ERROR_PAGE);
		}
		else {
			response.sendRedirect(SB_PAGE);
		}
	}
}
